package pv.map;

import java.util.ArrayList;
import java.util.List;

import pv.util.Utility;

import android.content.Context;
import android.location.Address;
import android.location.Geocoder;

import com.google.android.gms.maps.model.LatLng;

public class ConvertLatLong {

	public List<LatLng> convert(String address, Context context) {

		if (address == null || address.isEmpty()) {
			return null;
		}
		List<LatLng> result = new ArrayList<LatLng>();
		if (context == null)
			return null;
		Geocoder coder = new Geocoder(context);

		List<Address> listAddress;

		try {
			listAddress = coder.getFromLocationName(address, 5);

			if (listAddress == null) {
				return null;
			}
			for (int i = 0; i < listAddress.size(); i++) {
				Address location = listAddress.get(i);
				result.add(new LatLng(location.getLatitude(), location
						.getLongitude()));
			}

		} catch (Exception e) {
			// TODO: handle exception
			Utility.LogE(this.getClass(), e);
		}
		return result;
	}

}
